package com.mayi.zds.dao;

import com.mayi.zds.entity.Message;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @ClassName MessageDAO
 * @Description TODO
 * @Author zhong
 * @Date 2019/12/25 0025 下午 4:06
 * @Version 1.0
 */
@Repository
public interface MessageDAO {

    /**
     * 将消息存到数据库
     * @Author zhong
     * @Date 2019/12/25 16:09:27
     * @param message
     * @return void
     **/
    @Insert("insert into zds_message values(#{id},#{title},#{content},#{sendTime},#{businessId},#{riderId},#{orderId},#{status})")
    public void add(Message message);

    /**
     * 根据商户ID查询所有商户未读消息
     * @Author zhong
     * @Date 2019/12/25 16:18:08
     * @param bid
     * @return java.util.List<com.mayi.zds.entity.Message>
     **/
    @Select("select * from zds_message where business_id=#{bid} and status=1")
    public List<Message> getNotReadedMessageByBusiId(String bid);

    /**
     * 根据骑手ID查询所有骑手未读消息
     * @Author zhong
     * @Date 2019/12/25 16:18:08
     * @param rid
     * @return java.util.List<com.mayi.zds.entity.Message>
     **/
    @Select("select * from zds_message where rider_id=#{rid} and status=1")
    public List<Message> getNotReadedMessageByRiderId(String rid);
}
